# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=py3-w3lib
_pkgname=w3lib
pkgver=2.1.2
pkgrel=1
pkgdesc="A library of web-related functions"
url="https://github.com/scrapy/w3lib"
arch="noarch"
license="BSD-3-Clause"
depends="python3"
makedepends="py3-setuptools py3-gpep517 py3-wheel"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/scrapy/w3lib/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-w3lib" # Backwards compatibility
provides="py-w3lib=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer "$builddir"/.dist/*.whl
	.testenv/bin/python3 -m pytest -v
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
ed951a78233065e70b45d52401be14723e92a69ce34756afa74fc0a75f170239f69dfd35d1819b91eeaea74d6748f7893b303cc9d321a6b6dae6cd8a672353e9  py3-w3lib-2.1.2.tar.gz
"
